package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import lombok.*;

import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class Hotel extends BaseDomain {

    public static final Integer STATE_DISABLE = 0; //禁用
    public static final Integer STATE_NOMAL = 1; //正常
    public static final Integer STATE_COMMEND = 2; //推荐

    private String name;

    private String coverUrl;

    private Region city;

    private HotelDictionaryItem business;

    private HotelDictionaryItem traffic;

    private String address;

    private String tel;

    private String minPrice;

    private Integer state;
    private String intro;

    public String getStateName() {
        String str = "正常";
        if (state == STATE_DISABLE) {
            str = "禁用";
        } else if (state == STATE_COMMEND) {
            str = "推荐";
        }
        return str;
    }

    public Object getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("coverUrl", coverUrl);

        if (city != null) {
            map.put("cityId", city.getId());
            map.put("cityName", city.getName());
        }

        if (business != null) {
            map.put("businessId", business.getId());
            map.put("businessName", business.getTitle());
        }

        if (traffic != null) {
            map.put("trafficId", traffic.getId());
            map.put("trafficName", traffic.getTitle());
        }

        map.put("address", address);
        map.put("tel", tel);
        map.put("minPrice", minPrice);

        map.put("state", state);

        return JSON.toJSONString(map);
    }


}